import http from '@/http/index'

export default {
  /**
   * 获取站点名称
   * @returns {*}
   */
  getSiteName() {
    return http({
      url: '/api/index/getSiteName',
      method: 'get',
    })
  },

  /**
   * 获取访问计数
   * @returns {*}
   */
  getAccessCount() {
    return http({
      url: '/api/index/access',
      method: 'get',
    })
  },

  /**
   * 获取支付方式
   * @returns {*}
   */
  getTypes() {
    return http({
      url: '/api/index/getTypes',
      method: 'get',
    })
  },

  /**
   * 创建订单
   * @param params
   * @returns {*}
   */
  donation(params) {
    return http({
      url: '/api/pay/order',
      method: 'post',
      data: params,
      loading: true,
    })
  },

  /**
   * 获取订单状态
   * @param tradeNo 订单号
   * @returns {*}
   */
  getTradeStatus(tradeNo) {
    return http({
      url: `/api/pay/getTradeStatus/${tradeNo}`,
      method: 'get',
    })
  },

  /**
   * 获取捐赠者列表
   * @param page
   * @param size
   * @returns {*}
   */
  getDonationPage(page, size) {
    return http({
      url: `/api/donation/getPage/${page}/${size}`,
      method: 'get',
      loading: true,
    })
  },

  /**
   * 登陆
   * @returns {*}
   */
  login(data) {
    return http({
      url: '/api/auth/login',
      method: 'post',
      data,
      loading: true,
    })
  },

  /**
   * 获取登陆状态
   * 登陆状态会返回用户名, 没状态会返回401
   * @returns {*}
   */
  getLoginStatus() {
    return http({
      url: '/api/admin/getLoginStatus',
      method: 'get',
    })
  },

  /**
   * 更新资料
   * @returns {*}
   */
  updateProfile(data) {
    return http({
      url: '/api/admin/updateProfile',
      method: 'put',
      data,
      loading: true,
    })
  },

  /**
   * 获取支付方式列表
   * @returns {*}
   */
  getTypePage(page, size) {
    return http({
      url: `/api/admin/type/getPage/${page}/${size}`,
      method: 'get',
      loading: true,
    })
  },

  /**
   * 增加或更新支付类型
   * @param data
   * @returns {*}
   */
  addOrUpdateType(data) {
    return http({
      url: '/api/admin/type/saveOrUpdate',
      method: 'post',
      data,
      loading: true,
    })
  },

  /**
   * 删除支付方式
   * @param id 支付方式ID
   * @returns {*}
   */
  delType(id) {
    return http({
      url: `/api/admin/type/delete/${id}`,
      method: 'delete',
      loading: true,
    })
  },

  /**
   * 获取订单列表
   * @param page
   * @param size
   * @param conditions 条件
   * @returns {*}
   *
   */
  getAdminDonationPage(page, size, conditions) {
    return http({
      url: `/api/admin/donation/getPage/${page}/${size}`,
      method: 'post',
      data: conditions,
      loading: true,
    })
  },

  /**
   * 按照ID删除捐赠记录
   * @param id
   * @returns {*}
   */
  deleteDonationById(id) {
    return http({
      url: `/api/admin/donation/delete/${id}`,
      method: 'delete',
      loading: true,
    })
  },

  /**
   * 清理未支付订单
   * @returns {*}
   */
  clearNoPaid() {
    return http({
      url: `/api/admin/donation/clearNoPaid`,
      method: 'delete',
      loading: true,
    })
  },

  /**
   * 获取仪表盘信息
   * @returns {*}
   */
  getDashboard() {
    return http({
      url: '/api/admin/getDashboard',
      method: 'get',
      loading: true,
    })
  },

  /**
   * 获取服务器内存信息
   * @returns {*}
   */
  getMemoryInfo() {
    return http({
      url: '/api/admin/getMemoryInfo',
      method: 'get',
    })
  },

  /**
   * 获取服务器CPU信息
   * @returns {*}
   */
  getCpuInfo() {
    return http({
      url: '/api/admin/getCpuInfo',
      method: 'get',
    })
  },

  /**
   * 注销登陆
   * @returns {*}
   */
  logout() {
    return http({
      url: '/api/admin/logout',
      method: 'get',
      loading: true,
    })
  },
  getBingImg() {
    return http({
      url: '/api/admin/getBingImg',
      method: 'get',
    })
  },
}
